package com.cooba.activitys;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.TextView;

import com.cooba.R;
/**
 * Created by Administrator on 2015/1/5.
 * 视频详情
 */
public class VideoDetailsActivity extends AppCompatActivity {
    private WebView wb_video;
    private WebSettings settings;
    private String videoUrl,videoTitle,videoDs;
    private TextView video_title, video_ds;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_details);
        wb_video = (WebView) findViewById(R.id.wb_video);
        video_title = (TextView) findViewById(R.id.video_title);
        video_ds = (TextView) findViewById(R.id.video_ds);
        settings = wb_video.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setPluginState(WebSettings.PluginState.ON);
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setAllowFileAccess(true);
        settings.setDefaultTextEncodingName("UTF-8");
        settings.setLoadWithOverviewMode(true);
        settings.setUseWideViewPort(true);
        wb_video.setVisibility(View.VISIBLE);


        wb_video.setWebChromeClient(new WebChromeClient());
        settings.setTextSize(WebSettings.TextSize.NORMAL);
        settings.setDefaultTextEncodingName("UTF-8");
        settings.setJavaScriptEnabled(true);
        Intent intent = getIntent();
        videoUrl = intent.getStringExtra("videoUrl");
        videoTitle = intent.getStringExtra("videoTitle");
        videoDs = intent.getStringExtra("videoDs");
       video_title.setText(videoTitle);
       video_ds.setText(videoDs);
       Log.e("videoUrl", "videoUrl>>>>" + videoUrl);
       Log.e("videoUrl", "videoTitle>>>>" + videoTitle);
       Log.e("videoUrl", "videoDs>>>>" + videoDs);

      wb_video.loadUrl(videoUrl);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    // 设置回退
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK) && wb_video.canGoBack()) {
            wb_video.goBack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
